package com.sg.file.transform.provider.center;

import com.sg.file.transform.api.dto.TransformReqeust;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.EncoderException;
import it.sauronsoftware.jave.EncodingAttributes;
import lombok.extern.slf4j.Slf4j;

import java.io.File;

/**
 * Created by asus on 2018/7/17.
 */
@Slf4j
public abstract class FFmpegTranscode implements TransformCode {

    private Encoder encoder = new Encoder();

    @Override
    public void doTransform(TransformReqeust transformReqeust) throws EncoderException {
        transformReqeust.getTransformToFileSizeType();
        //获取转换参数
        EncodingAttributes encodingAttributes = getEncodeAttr(transformReqeust);
        encoder.encode(new File(transformReqeust.getOriginFilePath())
                ,new File(transformReqeust.getTransformFilePath())
                ,encodingAttributes);

    }

    public abstract EncodingAttributes getEncodeAttr(TransformReqeust transformReqeust);

}
